package com.jjsj.mall.service.impl;

import com.jjsj.mall.entity.MallSetting;
import com.jjsj.mall.mapper.MallSettingMapper;
import com.jjsj.mall.service.IMallSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商城设置Service业务层处理
 *
 * @author www.jjsjshop.com
 * @date 2022-10-10
 */
@Service
public class MallSettingServiceImpl implements IMallSettingService {
    @Autowired
    private MallSettingMapper mallSettingMapper;

    /**
     * 查询商城设置
     *
     * @param id 商城设置ID
     * @return 商城设置
     */
    @Override
    public MallSetting selectMallSettingById(Long id) {
        return mallSettingMapper.selectMallSettingById(id);
    }

    /**
     * 查询商城设置列表
     *
     * @param mallSetting 商城设置
     * @return 商城设置
     */
    @Override
    public List<MallSetting> selectMallSettingList(MallSetting mallSetting) {
        return mallSettingMapper.selectMallSettingList(mallSetting);
    }

    /**
     * 新增商城设置
     *
     * @param mallSetting 商城设置
     * @return 结果
     */
    @Override
    public int insertMallSetting(MallSetting mallSetting) {
        return mallSettingMapper.insertMallSetting(mallSetting);
    }

    /**
     * 修改商城设置
     *
     * @param mallSetting 商城设置
     * @return 结果
     */
    @Override
    public int updateMallSetting(MallSetting mallSetting) {
        List<MallSetting> list = this.selectMallSettingList(new MallSetting());
        for (MallSetting m : list) {
            this.deleteMallSettingById(m.getId());
        }
        return mallSettingMapper.insertMallSetting(mallSetting);
    }

    /**
     * 批量删除商城设置
     *
     * @param ids 需要删除的商城设置ID
     * @return 结果
     */
    @Override
    public int deleteMallSettingByIds(Long[] ids) {
        return mallSettingMapper.deleteMallSettingByIds(ids);
    }

    /**
     * 删除商城设置信息
     *
     * @param id 商城设置ID
     * @return 结果
     */
    @Override
    public int deleteMallSettingById(Long id) {
        return mallSettingMapper.deleteMallSettingById(id);
    }
}
